﻿using System.Collections.Generic;
using System.Text;
using UnityEngine;
using Debug = UnityEngine.Debug;

namespace Util
{
    public static partial class StringTool
    {
        public const char Split1 = ';';
        public const char Split2 = '|';
        public const char Split3 = '/';
        public const char Split4 = '~';
        public const char Split5 = '^';
        //private static StringBuilder sb = new StringBuilder();

        public static Quaternion toQuaternion(this string value)
        {
            var splitValue = value.toFloatList(Split1);
            return new Quaternion(splitValue[0], splitValue[1], splitValue[2], splitValue[3]);
        }

        /// <summary>
        /// 字符串转int
        /// </summary>
        /// <param name="s">字符串</param>
        /// <returns></returns>
        public static int toInt(this string s)
        {
            int v = -1;
            if (s == null)
            {
                return -1;
            }
            try
            {
                if (s.Length > 0 && ((s[0] >= '0' && s[0] <= '9') || s[0] == '-'))
                {
                    v = int.Parse(s);
                }
                else
                {
                    sb.Remove(0, sb.Length);
                    for (int i = 0; i < s.Length; i++)
                    {
                        if ((s[i] >= '0' && s[i] <= '9') || s[i] == '-')
                        {
                            sb.Append(s[i]);
                        }
                    }
                    if (sb.Length <= 0)
                    {
                        //debug.log("转换 int 解析失败!!  ", s);
                        v = -1;
                    }
                    else
                    {
                        v = int.Parse(sb.ToString());
                    }
                }
            }
            catch (System.Exception ex)
            {
                Debug.Log("转换 int  数值出错 !!!!" + s + ex.ToString());
            }
            return v;
        }

        public static float toFloat(this string s)
        {
            float v = -1;
            try
            {
                v = float.Parse(s);
            }
            catch (System.Exception ex)
            {
                //debug.log(debug.Level.error_3, "转换 float 错误!!!!", s, ex.ToString());
            }
            return v;
        }

        /// <summary>
        /// 字符串转intList
        /// </summary>
        public static int[] toIntArr(this string s, char gap = Split1)
        {
            string[] satt = s.toSplit(gap);
            int item = 0;
            int[] list = new int[satt.Length];
            for (int i = 0; i < satt.Length; i++)
            {
                try
                {
                    item = int.Parse(satt[i]);
                }
                catch (System.Exception ex)
                {
                    //debug.log(debug.Level.error_3, ex.ToString());
                }
                list[i] = item;
            }
            return list;
        }

        public static string[] toSplit(this string s, char gap = Split1)
        {
            if (s.isNull())
            {
                return new string[0];
            }
            string[] vs = s.Split(gap);
            if (vs == null || vs.Length <= 0)
            {
                vs = new string[1];
                vs[0] = s;
            }
            return vs;
        }

        public static List<byte> toByteList(this string s, char gap = Split1)
        {
            string[] satt = s.toSplit(gap);
            byte item = 0;
            List<byte> list = new List<byte>();
            for (int i = 0; i < satt.Length; i++)
            {
                try
                {
                    item = byte.Parse(satt[i]);
                }
                catch (System.Exception ex)
                {
                    Debug.LogError(satt[i] + " \n " + ex.ToString());
                }
                list.Add(item);
            }
            return list;
        }

        public static Dictionary<int, int> toDictIntInt(this string s, char split1 = Split2, char split2 = Split1)
        {
            Dictionary<int, int> keyValues = new Dictionary<int, int>();
            var arr = s.toSplit(split1);
            for (int i = 0; i < arr.Length; i++)
            {
                var curv = arr[i].toIntList(split2);
                keyValues.Add(curv[0], curv[1]);
            }
            return keyValues;
        }

        public static Dictionary<int, float> toDictIntFloat(this string str, char split1 = Split2, char split2 = Split1)
        {
            Dictionary<int, float> tempdict = new Dictionary<int, float>();
            var arr = str.toSplit(split1);
            for (int i = 0; i < arr.Length; i++)
            {
                var curv = arr[i].toSplit(split2);
                tempdict.Add(curv[0].toInt(), curv[1].toFloat());
            }
            return tempdict;
        }

        public static Dictionary<int, string> toDictIntString(this string str, char split1 = Split2, char split2 = Split1)
        {
            Dictionary<int, string> tempdict = new Dictionary<int, string>();
            var arr = str.toSplit(split1);
            for (int i = 0; i < arr.Length; i++)
            {
                var curv = arr[i].toSplit(split2);
                tempdict.Add(curv[0].toInt(), curv[1]);
            }
            return tempdict;
        }

        public static Dictionary<string, int> toDictStringInt(this string str, char split1 = Split2, char split2 = Split1)
        {
            Dictionary<string, int> tempdict = new Dictionary<string, int>();
            var arr = str.toSplit(split1);
            for (int i = 0; i < arr.Length; i++)
            {
                var curv = arr[i].toSplit(split2);
                tempdict.Add(curv[0], curv[1].toInt());
            }
            return tempdict;
        }

        public static Dictionary<string, float> toDictStringFloat(this string str, char split1 = Split2, char split2 = Split1)
        {
            Dictionary<string, float> tempdict = new Dictionary<string, float>();
            var arr = str.toSplit(split1);
            for (int i = 0; i < arr.Length; i++)
            {
                var curv = arr[i].toSplit(split2);
                tempdict.Add(curv[0], curv[1].toFloat());
            }
            return tempdict;
        }

        public static Dictionary<string, string> toDictStringString(this string str, char split1 = Split2, char split2 = Split1)
        {
            Dictionary<string, string> tempdict = new Dictionary<string, string>();
            var arr = str.toSplit(split1);
            for (int i = 0; i < arr.Length; i++)
            {
                var curv = arr[i].toSplit(split2);
                if (curv.Length == 2)
                {
                    tempdict.Add(curv[0], curv[1]);
                }
            }
            return tempdict;
        }

        public static Vector2 toVector2(this string s, char gap = Split1)
        {
            var vs = s.toFloatList(gap);
            Vector2 vector2 = new Vector2();
            if (vs.Count == 2)
            {
                vector2.x = vs[0];
                vector2.y = vs[1];
            }
            else
            {
                //debug.log("使用toVector2 参数错误", s);
            }

            return vector2;
        }

        public static Vector3 toVector3(this string str, char split = Split1)
        {
            var strs = str.toFloatList(split);
            return new Vector3(strs[0], strs[1], strs[2]);
        }

        public static Vector4 toVector4(this string str, char split = Split1)
        {
            var strs = str.toFloatList(split);
            return new Vector4(strs[0], strs[1], strs[2], strs[3]);
        }

        public static Color toColor(this string s, char split = Split1)
        {
            var splitValue = s.toFloatList(split);
            return new Color(splitValue[0], splitValue[1], splitValue[2], splitValue[3]);
        }

        public static Color32 toColor32(this string s, char split = Split1)
        {
            var splitValue = s.toByteList(split);
            return new Color32(splitValue[0], splitValue[1], splitValue[2], splitValue[3]);
        }
        public static void toStringIn(this Transform tf, string s, char split1 = Split2, char split2 = Split1)
        {
            var splitValue = s.toStringList(split1);
            tf.position = splitValue[0].toVector3(split2);
            tf.localEulerAngles = splitValue[1].toVector3(split2);
            tf.localScale = splitValue[2].toVector3(split2);
        }

        public static Rect toRect(this string s)
        {
            var splitValue = s.toFloatList(Split1);
            return new Rect(splitValue[0], splitValue[1], splitValue[2], splitValue[3]);
        }

        public static List<Vector2> toListVector2(this string str, char split1 = Split2, char split2 = Split1)
        {
            List<Vector2> templist = new List<Vector2>();
            var strs = str.toSplit(split1);
            for (int i = 0; i < strs.Length; i++)
            {
                templist.Add(strs[i].toVector2(split2));
            }

            return templist;
        }

        public static List<Vector3> toListVector3(this string str, char split1 = Split2, char split2 = Split1)
        {
            List<Vector3> templist = new List<Vector3>();
            var strs = str.toSplit(split1);
            for (int i = 0; i < strs.Length; i++)
            {
                templist.Add(strs[i].toVector3(split2));
            }

            return templist;
        }

        public static List<Vector4> toListVector4(this string str, char split1 = Split2, char split2 = Split1)
        {
            List<Vector4> templist = new List<Vector4>();
            var strs = str.toSplit(split1);
            for (int i = 0; i < strs.Length; i++)
            {
                templist.Add(strs[i].toVector4(split2));
            }

            return templist;
        }

        /// <summary>
        /// 字符串 list
        /// </summary>
        /// <param name="s"></param>
        /// <param name="gap"></param>
        /// <returns></returns>
        public static List<string> toStringList(this string s, char gap = Split1)
        {
            return new List<string>(s.toSplit(gap));
        }

        /// <summary>
        /// 字符串矩阵list row行分割符号 pos位置分割符号
        /// </summary>
        /// <param name="s"></param>
        /// <param name="row"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        public static List<List<string>> toStringMatrixList(this string s, char row = Split2, char pos = Split1)
        {
            List<List<string>> Matrix = new List<List<string>>();
            string[] rowatt = s.toSplit(row);
            for (int i = 0; i < rowatt.Length; i++)
            {
                Matrix.Add(new List<string>(rowatt[i].toSplit(pos)));
            }
            return Matrix;
        }

        /// <summary>
        /// 字符串空间list axis1 z纬度, axis2 y纬度, axis3 x纬度
        /// </summary>
        /// <param name="s"></param>
        /// <param name="axis1"></param>
        /// <param name="axis2"></param>
        /// <param name="axis3"></param>
        /// <returns></returns>
        public static List<List<List<string>>> toStringSpaceList(this string s, char axis1 = Split3, char axis2 = Split2, char axis3 = Split1)
        {
            List<List<List<string>>> Matrix = new List<List<List<string>>>();
            string[] xs = s.toSplit(axis1);
            for (int x = 0; x < xs.Length; x++)
            {
                List<List<string>> yl = new List<List<string>>();
                string[] ys = xs[x].toSplit(axis2);
                for (int y = 0; y < ys.Length; y++)
                {
                    List<string> zl = new List<string>(ys[y].toSplit(axis3));
                    yl.Add(zl);
                }
                Matrix.Add(yl);
            }
            return Matrix;
        }

        /// <summary>
        /// 字符串转intList
        /// </summary>
        public static List<int> toIntList(this string s, char gap = Split1)
        {
            string[] satt = s.toSplit(gap);
            int item = 0;
            List<int> list = new List<int>();
            for (int i = 0; i < satt.Length; i++)
            {
                try
                {
                    item = satt[i].toInt();
                }
                catch (System.Exception ex)
                {
                    Debug.LogError(ex.ToString());
                }
                list.Add(item);
            }
            return list;
        }

        /// <summary>
        /// int矩阵 row行分割符号 pos位置分割符号
        /// </summary>
        /// <param name="s"></param>
        /// <param name="row"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        public static List<List<int>> toIntMatrixList(this string s, char row = Split2, char pos = Split1)
        {
            List<List<int>> Matrix = new List<List<int>>();
            string[] rowatt = s.toSplit(row);
            for (int j = 0; j < rowatt.Length; j++)
            {
                int item = 0;
                string[] satt = rowatt[j].toSplit(pos);
                List<int> list = new List<int>();
                for (int i = 0; i < satt.Length; i++)
                {
                    try
                    {
                        item = satt[i].toInt();
                    }
                    catch (System.Exception ex)
                    {
                        Debug.LogError(ex.ToString());
                    }
                    list.Add(item);
                }
                Matrix.Add(list);
            }
            return Matrix;
        }

        /// <summary>
        /// Int空间list axis1 z纬度, axis2 y纬度, axis3 x纬度
        /// </summary>
        /// <param name="s"></param>
        /// <param name="axis1"></param>
        /// <param name="axis2"></param>
        /// <param name="axis3"></param>
        /// <returns></returns>
        public static List<List<List<int>>> toIntSpaceList(this string s, char axis1 = Split3, char axis2 = Split2, char axis3 = Split1)
        {
            List<List<List<int>>> Matrix = new List<List<List<int>>>();
            string[] xs = s.toSplit(axis1);
            for (int x = 0; x < xs.Length; x++)
            {
                List<List<int>> yl = new List<List<int>>();
                string[] ys = xs[x].toSplit(axis2);
                for (int y = 0; y < ys.Length; y++)
                {
                    List<int> zl = new List<int>();
                    string[] zs = ys[y].toSplit(axis3);
                    for (int z = 0; z < zs.Length; z++)
                    {
                        int zv = zs[z].toInt();
                        zl.Add(zv);
                    }
                    yl.Add(zl);
                }
                Matrix.Add(yl);
            }
            return Matrix;
        }

        /// <summary>
        /// 字符串转FloatList
        /// </summary>
        public static List<float> toFloatList(this string s, char gap = Split1)
        {
            string[] satt = s.toSplit(gap);
            float item = 0;
            List<float> list = new List<float>();
            for (int i = 0; i < satt.Length; i++)
            {
                try
                {
                    item = satt[i].toFloat();
                }
                catch (System.Exception ex)
                {
                    Debug.LogError(ex.ToString());
                }
                list.Add(item);
            }
            return list;
        }

        /// <summary>
        /// float矩阵 row行分割符号 pos位置分割符号
        /// </summary>
        /// <param name="s"></param>
        /// <param name="row"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        public static List<List<float>> toFloatMatrixList(this string s, char row = Split2, char pos = Split1)
        {
            List<List<float>> Matrix = new List<List<float>>();
            string[] rowatt = s.toSplit(row);
            for (int j = 0; j < rowatt.Length; j++)
            {
                float item = 0;
                string[] satt = rowatt[j].toSplit(pos);
                List<float> list = new List<float>();
                for (int i = 0; i < satt.Length; i++)
                {
                    try
                    {
                        item = satt[i].toFloat();
                    }
                    catch (System.Exception ex)
                    {
                        Debug.LogError(ex.ToString());
                    }
                    list.Add(item);
                }
                Matrix.Add(list);
            }
            return Matrix;
        }

        /// <summary>
        /// float空间list axis1 z纬度, axis2 y纬度, axis3 x纬度
        /// </summary>
        /// <param name="s"></param>
        /// <param name="axis1"></param>
        /// <param name="axis2"></param>
        /// <param name="axis3"></param>
        /// <returns></returns>
        public static List<List<List<float>>> toFloatSpaceList(this string s, char axis1 = Split3, char axis2 = Split2, char axis3 = Split1)
        {
            List<List<List<float>>> Matrix = new List<List<List<float>>>();
            string[] xs = s.toSplit(axis1);
            for (int x = 0; x < xs.Length; x++)
            {
                List<List<float>> yl = new List<List<float>>();
                string[] ys = xs[x].toSplit(axis2);
                for (int y = 0; y < ys.Length; y++)
                {
                    List<float> zl = new List<float>();
                    string[] zs = ys[y].toSplit(axis3);
                    for (int z = 0; z < zs.Length; z++)
                    {
                        float zv = zs[z].toFloat();
                        zl.Add(zv);
                    }
                    yl.Add(zl);
                }
                Matrix.Add(yl);
            }
            return Matrix;
        }

        //---------------------------------------------------------------------------------------------------------------------------------------------------------

        public static string toString(this Rect s)
        {
            string v = (new List<float>() { s.x.toRound(2), s.y.toRound(2), s.width.toRound(2), s.height.toRound(2) }).toStringArray();
            return v;
        }

        public static string toStringArray<T>(this List<T> list, char split1 = Split1)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.Count; i++)
            {
                sb.Append(list[i]);
                if (i != list.Count - 1)
                {
                    sb.Append(split1);
                }
            }
            return sb.ToString();
        }

        public static string toStringMatrix<T>(this List<List<T>> list, char row = Split2, char pos = Split1)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.Count; i++)
            {
                var t = list[i];
                for (int j = 0; j < t.Count; j++)
                {
                    sb.Append(t);
                    if (i != t.Count - 1)
                        sb.Append(pos);
                }
                if (i != list.Count - 1)
                    sb.Append(row);
            }
            return sb.ToString();
        }

        public static string toStringSpace<T>(this List<List<List<T>>> list, char axis1 = Split3, char axis2 = Split2, char axis3 = Split1)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.Count; i++)
            {
                var t = list[i];
                for (int j = 0; j < t.Count; j++)
                {
                    var z = t[j];
                    for (int k = 0; k < z.Count; k++)
                    {
                        var c = z[k];
                        sb.Append(c);
                        if (i != z.Count - 1)
                            sb.Append(axis3);
                    }
                    if (i != t.Count - 1)
                        sb.Append(axis2);
                }
                if (i != list.Count - 1)
                    sb.Append(axis1);
            }
            return sb.ToString();
        }

        public static string toStringDic<T1, T2>(this Dictionary<T1, T2> dic, char row = Split2, char pos = Split1)
        {
            StringBuilder sb = new StringBuilder();
            var klist = new List<T1>(dic.Keys);
            var vlist = new List<T2>(dic.Values);
            int num = dic.Count;
            for (int i = 0; i < num; i++)
            {
                sb.Append(klist[i]);
                sb.Append(pos);
                sb.Append(vlist[i]);
                if (i != num - 1)
                    sb.Append(row);
            }
            return sb.ToString();
        }

        public static string toString(this Vector2 s, char gap = Split1)
        {
            return string.Format("{0}{1}{2}", s.x, gap, s.y);
        }

        public static string toString(this Vector3 str, char split = Split1)
        {
            return string.Format("{0}{1}{2}{3}{4}", str.x, split, str.y, split, str.z);
        }

        public static string toString(this Vector4 str, char split = Split1)
        {
            return string.Format("{0}{1}{2}{3}{4}{3}{4}", str.x, split, str.y, split, str.z, split, str.w);
        }

        public static string toString(this Color s, char split = Split1)
        {
            return string.Format("{0}{1}{2}{3}{4}{3}{4}", s.r, split, s.g, split, s.b, split, s.a);
        }

        public static string toString(this Color32 s, char split = Split1)
        {
            return string.Format("{0}{1}{2}{3}{4}{3}{4}", s.r, split, s.g, split, s.b, split, s.a);
        }

        public static string toString(this Rect s, char split = Split1)
        {
            return string.Format("{0}{1}{2}{3}{4}{3}{4}", s.x, split, s.y, split, s.width, split, s.height);
        }

        public static string toString(this Transform tf, char split1 = Split2, char split2 = Split1)
        {
            Vector3 pos = tf.localPosition;
            Vector3 sca = tf.localScale;
            Vector3 ea = tf.localEulerAngles;
            string s = new List<string>() { pos.toString(split2), ea.toString(split2), sca.toString(split2) }.toStringArray(split1);
            return s;
        }
    }

    #region 自定义字符串解析类

    public struct DicIntString
    {
        public Dictionary<int, string> vs;
        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public string this[int index]
        {
            get
            {
                string v = "-1";
                if (!vs.TryGetValue(index, out v))
                {
                    v = "-1";
                }
                return v;
            }
        }

        public DicIntString(string s)
        {
            if (s == string.Empty)
                vs = new Dictionary<int, string>();
            else
                vs = s.toDictIntString();
        }

        public Dictionary<int, string> toDic()
        {
            return vs;
        }
    }

    public struct DicStringString
    {
        public Dictionary<string, string> vs;
        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public string this[string index]
        {
            get
            {
                string v = "-1";
                if (!vs.TryGetValue(index, out v))
                {
                    v = "-1";
                }
                return v;
            }
        }

        public DicStringString(string s)
        {
            if (s == string.Empty)
                vs = new Dictionary<string, string>();
            else
                vs = s.toDictStringString();
        }

        public Dictionary<string, string> toDic()
        {
            return vs;
        }
    }

    public struct DicIntInt
    {
        public Dictionary<int, int> vs;
        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public int this[int index]
        {
            get
            {
                int v = -1;
                if (!vs.TryGetValue(index, out v))
                {
                    v = -1;
                }
                return v;
            }
        }

        public DicIntInt(string s)
        {
            if (s == string.Empty)
                vs = new Dictionary<int, int>();
            else
                vs = s.toDictIntInt();
        }

        public Dictionary<int, int> toDic()
        {
            return vs;
        }
    }

    public struct DicIntFloat
    {
        public Dictionary<int, float> vs;
        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public float this[int index]
        {
            get
            {
                float v = -1;
                if (!vs.TryGetValue(index, out v))
                {
                    v = -1;
                }
                return v;
            }
        }

        public DicIntFloat(string s)
        {
            if (s == string.Empty)
                vs = new Dictionary<int, float>();
            else
                vs = s.toDictIntFloat();
        }

        public Dictionary<int, float> toDic()
        {
            return vs;
        }
    }

    //数组字符串 例如: as|sdd|dff
    public struct ArrayString
    {
        private List<string> vs;

        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public string this[int index]
        {
            get
            {
                string v = "-1";
                if (index >= 0 && index < vs.Count && vs != null)
                {
                    v = vs[index];
                }
                return v;
            }
        }

        public ArrayString(string s)
        {
            if (s == string.Empty)
                vs = new List<string>();
            else
                vs = s.toStringList(StringTool.Split1);
        }

        public List<string> toList()
        {
            return vs;
        }
    }

    //矩阵字符串 例如:as|sdd|dff/as|sdd|dff/as|sdd|dff
    public struct MatrixString
    {
        private List<List<string>> vs;
        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public string this[int row, int pos]
        {
            get
            {
                string v = "-1";
                if (row >= 0 && row < vs.Count && vs != null)
                {
                    if (pos >= 0 && pos < vs[row].Count && vs[row] != null)
                        v = vs[row][pos];
                }
                return v;
            }
        }

        public MatrixString(string s)
        {
            if (s == string.Empty)
                vs = new List<List<string>>();
            else
                vs = s.toStringMatrixList(StringTool.Split2, StringTool.Split1);
        }

        public List<List<string>> toList()
        {
            return vs;
        }
    }

    //空间字符串 例如:as|sdd|dff/as|sdd|dff/as|sdd|dff^as|sdd|dff/as|sdd|dff/as|sdd|dff
    public struct SpaceString
    {
        private List<List<List<string>>> vs;
        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public string this[int axis1, int axis2, int axis3]
        {
            get
            {
                string v = "-1";
                if (axis1 >= 0 && axis1 < vs.Count && vs != null)
                    if (axis2 >= 0 && axis2 < vs[axis1].Count && vs[axis1] != null)
                        if (axis3 >= 0 && axis3 < vs[axis1][axis2].Count && vs[axis1][axis2] != null)
                            v = vs[axis1][axis2][axis3];
                return v;
            }
        }

        public SpaceString(string s)
        {
            if (s == string.Empty)
                vs = new List<List<List<string>>>();
            else
                vs = s.toStringSpaceList(StringTool.Split3, StringTool.Split2, StringTool.Split1);
        }

        public List<List<List<string>>> toList()
        {
            return vs;
        }
    }

    //数组Int 例如: 1|2|3|2
    public struct ArrayInt
    {
        private List<int> vs;

        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public int this[int index]
        {
            get
            {
                int v = -1;
                if (index >= 0 && index < vs.Count && vs != null)
                {
                    v = vs[index];
                }
                return v;
            }
        }

        public ArrayInt(string s)
        {
            if (s == string.Empty)
                vs = new List<int>();
            else
                vs = s.toIntList(StringTool.Split1);
        }

        public List<int> toList()
        {
            return vs;
        }
    }

    //矩阵Int 例如: 1|2|3/1|2|3/1|2|3
    public struct MatrixInt
    {
        private List<List<int>> vs;

        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public int this[int row, int pos]
        {
            get
            {
                int v = -1;
                if (row >= 0 && row < vs.Count && vs != null)
                {
                    if (pos >= 0 && pos < vs[row].Count && vs[row] != null)
                        v = vs[row][pos];
                }
                return v;
            }
        }

        public MatrixInt(string s)
        {
            if (s == string.Empty)
                vs = new List<List<int>>();
            else
                vs = s.toIntMatrixList(StringTool.Split2, StringTool.Split1);
        }

        public List<List<int>> toList()
        {
            return vs;
        }
    }

    //空间Int 例如:as|sdd|dff/as|sdd|dff/as|sdd|dff^as|sdd|dff/as|sdd|dff/as|sdd|dff
    public struct SpaceInt
    {
        private List<List<List<int>>> vs;
        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public int this[int axis1, int axis2, int axis3]
        {
            get
            {
                int v = -1;
                if (axis1 >= 0 && axis1 < vs.Count && vs != null)
                    if (axis2 >= 0 && axis2 < vs[axis1].Count && vs[axis1] != null)
                        if (axis3 >= 0 && axis3 < vs[axis1][axis2].Count && vs[axis1][axis2] != null)
                            v = vs[axis1][axis2][axis3];
                return v;
            }
        }

        public SpaceInt(string s)
        {
            if (s == string.Empty)
                vs = new List<List<List<int>>>();
            else
                vs = s.toIntSpaceList(StringTool.Split3, StringTool.Split2, StringTool.Split1);
        }

        public List<List<List<int>>> toList()
        {
            return vs;
        }
    }

    //数组Float 例如:1|2.3|3.2|2
    public struct ArrayFloat
    {
        private List<float> vs;

        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public float this[int index]
        {
            get
            {
                float v = -1;
                if (index >= 0 && index < vs.Count && vs != null)
                {
                    v = vs[index];
                }
                return v;
            }
        }

        public ArrayFloat(string s)
        {
            if (s == string.Empty)
                vs = new List<float>();
            else
                vs = s.toFloatList(StringTool.Split1);
        }

        public List<float> toList()
        {
            return vs;
        }
    }

    //矩阵Float 1|2.3|3.2|2/1|2.3|3.2|2/1|2.3|3.2|2
    public struct MatrixFloat
    {
        private List<List<float>> vs;

        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public float this[int row, int pos]
        {
            get
            {
                float v = -1;
                if (row >= 0 && row < vs.Count && vs != null)
                {
                    if (pos >= 0 && pos < vs[row].Count && vs[row] != null)
                        v = vs[row][pos];
                }
                return v;
            }
        }

        public MatrixFloat(string s)
        {
            if (s == string.Empty)
                vs = new List<List<float>>();
            else
                vs = s.toFloatMatrixList(StringTool.Split2, StringTool.Split1);
        }

        public List<List<float>> toList()
        {
            return vs;
        }
    }

    //空间Float 1|2.3|3.2|2/1|2.3|3.2|2/1|2.3|3.2|2
    public struct SpaceFloat
    {
        private List<List<List<float>>> vs;
        public int Count { get { if (vs == null) { return 0; } return vs.Count; } }

        public float this[int axis1, int axis2, int axis3]
        {
            get
            {
                float v = -1;
                if (axis1 >= 0 && axis1 < vs.Count && vs != null)
                    if (axis2 >= 0 && axis2 < vs[axis1].Count && vs[axis1] != null)
                        if (axis3 >= 0 && axis3 < vs[axis1][axis2].Count && vs[axis1][axis2] != null)
                            v = vs[axis1][axis2][axis3];
                return v;
            }
        }

        public SpaceFloat(string s)
        {
            if (s == string.Empty)
                vs = new List<List<List<float>>>();
            else
                vs = s.toFloatSpaceList(StringTool.Split3, StringTool.Split2, StringTool.Split1);
        }

        public List<List<List<float>>> toList()
        {
            return vs;
        }
    }

    #endregion 自定义字符串解析类
}